home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / sdl212x.zip / MODULE.C < prev    next >
C/C++ Source or Header  |  1996-05-15  |  24KB  |  704 lines

  1. //////////////////////////////////////////////////////////////////////////
  2. // MODULE.C: An example for a module run from one of stardock loco's expansion
  3. // slots.  Feel free to use this code for any stardock loco modules.
  4.  
  5. // This was compiled using Borland Turbo C++ version 3.0
  6. // This will _not_ compile without Brian Pirie's Opendoors odoorh.lib (huge model)
  7.  
  8. // Also feel free to upgrade my version of Guido's Black Market.
  9. // Note: It is crucial to the game that they be able to upgrade their
  10. // armor and weapon strength at the higher levels!  Make sure to keep that
  11. // if you make a better black market.
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Do not distribute any modules that use unregistered serial comm libraries!
  15. /////////////////////////////////////////////////////////////////////////////
  16.  
  17. // Ok, enough of that, here's how I call this program.  This is the actual
  18. // code that I use to spawn _from_ stardock loco for anyone that goes into the
  19. // black market:    i.e. blkmkt1.exe
  20. //
  21. // Note:  This is nearly identical to, and works the same way from any expansion
  22. // slots in the game.  The 'Yards expansion slots gets the filepath from
  23. // the module.lst, and does the same thing as below.  The other slots
  24. // are run by using _dos_find_first to find the first occurance of the first
  25. // two letters.  See sd_devlp.txt for all the gruesome details.
  26. //
  27. // any od_control structure usage is from Brian Pirie's Opendoors 6.0 serial
  28. // comm library.  Get his program and register it.
  29. //
  30. // od_control.info_path is the path to the door.sys, or whatever the file
  31. // is that has the BBS information on the user.
  32. //
  33. //
  34. //   Make sure it's there, or look for an upgrade to blkmkt2.exe etc.
  35. //
  36. //    if( _dos_findfirst("blkmkt?.exe",_A_NORMAL,&ffblk) ==0)
  37. //        {
  38. //        update_player_file();  //update the player file before spawn
  39. //
  40. //            od_spawnvpe(P_WAIT,filepath,_argv,NULL);
  41. //        check_it();       //make sure they aren't dead.
  42. //                              - this is for real modules.
  43. //                                A person can't die in the black market.
  44. //        }
  45. //////////////////////////////////////////////////////////////////////////
  46. //
  47. //                         Guido's Black Market
  48. //                Formerly known as Indelgo's Black Market.
  49. //////////////////////////////////////////////////////////////////////////
  50. #include <string.h>
  51. #include <stdlib.h>
  52. #include <stdio.h>
  53. #include <dos.h>
  54. #include <time.h>
  55.  
  56. #include "opendoor.h"
  57. //from Brian Pirie's Opendoors 6.0 serial comm library
  58. //contains all the functions and structures necessary for comm routines.
  59.  
  60. //Update, I've begun using 6.0.  New things shall arise.  See the web site:
  61. //  http://www.starlink.com/~jam/ (Follow the links)
  62. //  http://www.starlink.com/~alanen  (My weird page)
  63.  
  64. #include <ctype.h>
  65. #include <errno.h>
  66.  
  67. //see sd_devlp.txt for all the information on this stuff.
  68. #define MAX 2
  69. #define MAXNAME  30
  70. #define    MAXBBSNAME 36
  71. #define    MAXWEAPONNAME 20
  72. #define    MAXARMORNAME 20
  73. #define MAXSTANDARDLONG 10
  74. #define MAXSTANDARDINT 4  //standard integer
  75. #define WAIT_FOR_FILE         10       /* Time to wait for access to file */
  76. FILE *OpenExclusiveFile(char *pszFileName, char *pszAccess, time_t Wait); //exclusive file access
  77. void update_player_file(void);
  78. void r_player_file(void);
  79. void WaitForEnter(void);
  80. void More(void);
  81. void door(void);
  82. void indelgos_bm(void);    //the module
  83. void change(void);    //formats numbers to nice numbers with commas
  84.  
  85. struct on_line_player   //See the sd_devlp.txt for further explanations!!
  86.     {
  87.     int on_now;
  88.     char name[MAXNAME+1];
  89.     char bbs_name[MAXBBSNAME+1];
  90.     int living;      //if alive = 1
  91.     char killer[MAXNAME+1];     //who killed player
  92.     int location;    //1 if in TP's, 2 if in pod
  93.     long lifepoints;
  94.     long lifepointsttl;
  95.  
  96.     char weapon[MAXWEAPONNAME+1];
  97.     unsigned long weapon_energy;
  98.     int weapon_strength;
  99.     unsigned long max_packs;
  100.     int weapon_status;
  101.     unsigned long weapon_cost;
  102.  
  103.     char armor[MAXARMORNAME+1];
  104.     unsigned long armor_strength;
  105.     int armor_status;
  106.     unsigned long armor_cost;
  107.  
  108.     unsigned long credits;
  109.     unsigned long bank_credit;
  110.  
  111.     int pod;
  112.  
  113.     int ship;
  114.     char ship_name[MAXNAME+1];
  115.     int ship_type;
  116.     int mt;              //matter transmitter
  117.     int arkon_bomb;
  118.  
  119.     //*extra data:
  120.     int level;
  121.     unsigned long experience;
  122.     int kills;
  123.     int droids;
  124.     int passkey;
  125.  
  126.    //assorted stuff *global* //
  127.     int on_off;    //on off for off-line droid attack
  128.     //reset daily by extern:   //from defaults....
  129.     int sickbay_closed;        //killed staff
  130.     int bank_closed;           //angered guido
  131.     int pickpocket;            //picked N. Wetlys pocket
  132.     int tipcnt;                //max tips taken
  133.     int owns;                 //1 owns weapon shop, 2 owns armor shop
  134.     int fights;                //fights per day 30?
  135.     int last_played;           //stardock days running
  136.     };
  137.  
  138. struct on_line_player current;
  139.  
  140. struct player
  141.     {
  142.     char on_now[MAXSTANDARDINT+1];
  143.     char name[MAXNAME+1];
  144.     char bbs_name[MAXBBSNAME+1];
  145.     char living[MAXSTANDARDINT+1];      //if alive = 1
  146.     char killer[MAXNAME+1];
  147.     char location[MAXSTANDARDINT+1];
  148.     char lifepoints[MAXSTANDARDLONG+1];
  149.     char lifepointsttl[MAXSTANDARDLONG+1];
  150.  
  151.     char weapon[MAXWEAPONNAME+1];
  152.     char weapon_energy[MAXSTANDARDLONG+1];
  153.     char weapon_strength[MAXSTANDARDINT+1];
  154.     char max_packs[MAXSTANDARDLONG+1];
  155.          //if they have a weapon = 1
  156.     char weapon_status[MAXSTANDARDINT+1];
  157.     char weapon_cost[MAXSTANDARDLONG+1];
  158.  
  159.     char armor[MAXARMORNAME+1];
  160.     char armor_strength[MAXSTANDARDLONG+1];
  161.     char armor_status[MAXSTANDARDINT+1];        //if they have armor = 1
  162.     char armor_cost[MAXSTANDARDLONG+1];
  163.  
  164.     char credits[MAXSTANDARDLONG+1];
  165.     char bank_credit[MAXSTANDARDLONG+1];
  166.  
  167.     char pod[MAXSTANDARDINT+1];
  168.  
  169.     char ship[MAXSTANDARDINT+1];
  170.     char ship_name[MAXNAME+1];
  171.     char ship_type[MAXSTANDARDINT+1];
  172.     char mt[MAXSTANDARDINT+1];
  173.     char arkon_bomb[MAXSTANDARDINT+1];
  174.  
  175.     char level[MAXSTANDARDINT+1];
  176.     char experience[MAXSTANDARDLONG+1];
  177.     char kills[MAXSTANDARDINT+1];
  178.     char droids[MAXSTANDARDINT+1];
  179.     char passkey[MAXSTANDARDINT+1];
  180.  
  181.      //globals
  182.     char on_off[MAXSTANDARDINT+1];
  183.     char sickbay_closed[MAXSTANDARDINT+1];
  184.     char bank_closed[MAXSTANDARDINT+1];
  185.     char pickpocket[MAXSTANDARDINT+1];
  186.     char tipcnt[MAXSTANDARDINT+1];
  187.     char owns[MAXSTANDARDINT+1];
  188.     char fights[MAXSTANDARDINT+1];
  189.     char last_played[MAXSTANDARDINT+1];
  190.     };
  191.  
  192.  
  193. int playerfound=0;
  194. char door_sys_name[MAXBBSNAME+1];
  195. int record_count;
  196. char number[14];  //for formatted credit amounts and such.  See change();
  197.  
  198.  
  199. //NEW:
  200. char sdpath[80];  //Path to SDL's player.lst.  It is contained in sdpath.dat
  201.  
  202.  
  203.  
  204.  
  205. //main()/WinMain() 32 bit is:
  206. //Straight out of Brian Pirie's example, ez_vote.c from Opendoors 6.0
  207. //This is his wording, coding, etc.  It works.  So I changed to his.
  208. //You don't have to include this for now, but it may help later when I
  209. //create a 32 bit version.  (Real one. :)
  210. /* main() or WinMain() function - Program execution begins here. */
  211. #ifdef ODPLAT_WIN32
  212. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  213.    LPSTR lpszCmdLine, int nCmdShow)
  214. #else
  215. int main(int argc, char *argv[])
  216. #endif
  217. {
  218.  
  219. #ifdef ODPLAT_WIN32
  220.    /* In Windows, pass in nCmdShow value to OpenDoors. */
  221.    od_control.od_cmd_show = nCmdShow;
  222.  
  223.    /* Ignore unused parameters. */
  224.    (void)hInstance;
  225.    (void)hPrevInstance;
  226. #endif
  227.  
  228.  
  229.    /* Set program's name for use by OpenDoors. */
  230.  
  231.    //Change this for yours please...<G>!
  232.    strcpy(od_control.od_prog_name, "Stardock Loco WIN95/NT - DOS 16bit");
  233.    strcpy(od_control.od_prog_version, "Version 1 BETA");
  234.    strcpy(od_control.od_prog_copyright, "Copyright 1995-1996 by Aaron Alanen");
  235.  
  236.    /* Call the standard command-line parsing function. You will probably     */
  237.    /* want to do this in most programs that you write using OpenDoors, as it */
  238.    /* automatically provides support for many standard command-line options  */
  239.    /* that will make the use and setup of your program easer. For details,   */
  240.    /* run the vote program with the /help command line option.